import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/Manage.vue'

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        name: 'Manage',
        component: ()=>import("../views/Manage.vue"),
        redirect:"/home",
        children:[
            {path: 'home',name: "首页",component:()=>import("../views/Home")},
            {path:'userManage',name:"用户管理",component:()=>import("../components/Manager")},
            {path: 'managerPerson',name: "个人信息",component:()=>import("../views/ManagerPerson")},
            {path: 'File',name: "文件管理",component:()=>import("../views/File")},
            {path: 'PbssManage',name: "充电宝投放点管理",component:()=>import("../views/Pbss")},
            {path: 'PbManage',name: "充电宝管理",component:()=>import("../views/Pb")},
            {path: 'MapManage',name: "地图展示",component:()=>import("../views/Map")},
            {path: 'OrderManage',name: '订单管理',component:()=>import("../views/OrderPage")},
            {path: 'logs',name: '操作日志',component:()=>import("../views/logs")}

        ]
    },
    {
        path: '/about',
        name: 'about',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
    },
    {
        path: '/manageLogin',
        name:"管理员登录",
        component:()=>import('../views/ManagerLogin')
    },
    {
        path: '/manageRegister',
        name:"管理员注册",
        component:()=>import('../views/Register'),

    },{
         path: '/userPage',
        name: "用户页面",
        component:()=>import("../views/user/userPage"),
        children: [
            {path: '/userPerson',name: "个人信息",component:()=>import('../views/user/userPerson')},
            {path: '/userPbPage',name: "充电宝租借",component:()=>import('../views/user/userPbPage')},
            {path: '/orderNow',name: "正在进行的订单",component:()=>import('../views/user/ordernow')},
            {path: '/orderhistory',name: "历史订单",component:()=>import('../views/user/orderhistory')},
            {path: '/bindIdCard',name: "身份绑定",component:()=>import('../views/user/IdentityBinding')},
            {path: '/userMap',name:"查找附近投放点位置",component:()=>import('../views/user/userMap')},
            {path: '/recharge',name:"充值中心",component:()=>import('../views/user/recharge')}
        ]
    },
    {
        path: '/userLogin',
        name:"用户登录",
        component:()=>import("../views/user/userLogin")
    },{
    path: '/userRegister',
        name: "用户注册",
        component:()=>import("../views/user/userRegister")
    },

]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

router.beforeEach((to, from, next) => {
   localStorage.setItem("currentPathName",to.name)
    next()
})


export default router
